package cn.community.care.module.system.dal.mysql.basicinfo;

import java.util.*;

import cn.community.care.framework.common.pojo.PageResult;
import cn.community.care.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.community.care.framework.mybatis.core.mapper.BaseMapperX;
import cn.community.care.module.system.controller.admin.basicinfo.vo.BasicInfoPageReqVO;
import cn.community.care.module.system.dal.dataobject.basicinfo.BasicInfoDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 用户基本信息 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface BasicInfoMapper extends BaseMapperX<BasicInfoDO> {

    default PageResult<BasicInfoDO> selectPage(BasicInfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BasicInfoDO>()
                .eqIfPresent(BasicInfoDO::getUserId, reqVO.getUserId())
                .likeIfPresent(BasicInfoDO::getName, reqVO.getName())
                .eqIfPresent(BasicInfoDO::getGender, reqVO.getGender())
                .betweenIfPresent(BasicInfoDO::getBirthDate, reqVO.getBirthDate())
                .eqIfPresent(BasicInfoDO::getIdNumber, reqVO.getIdNumber())
                .eqIfPresent(BasicInfoDO::getContactPhone, reqVO.getContactPhone())
                .eqIfPresent(BasicInfoDO::getHomeAddress, reqVO.getHomeAddress())
                .eqIfPresent(BasicInfoDO::getMaritalStatus, reqVO.getMaritalStatus())
                .betweenIfPresent(BasicInfoDO::getCheckInDate, reqVO.getCheckInDate())
                .betweenIfPresent(BasicInfoDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BasicInfoDO::getId));
    }

}